package com.cyf.plc.model

import android.os.Parcelable
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import kotlinx.android.parcel.IgnoredOnParcel
import kotlinx.android.parcel.Parcelize
import java.io.Serializable

@Entity
@Parcelize
data class PlcAttribute(
    //存储用主键
    @PrimaryKey var attributeId: String = "",
    var offSet: Int,
    var addressUnit: String,
    var attributeName: String,
    var name: String
) : Comparable<PlcAttribute>, Parcelable, Serializable {

    @IgnoredOnParcel
    @Ignore
    var value: Float = -1f

    override fun compareTo(other: PlcAttribute): Int {
        //从小到大排序  this在前
        //从大到小排序 o在前
        return offSet - other.offSet
    }

    override fun toString(): String {
        return "PlcAttribute(attributeId='$attributeId', offSet=$offSet, addressUnit='$addressUnit', attributeName='$attributeName', value=$value)"
    }
}